<HTML><HEAD><TITLE>current_pragma(?Pragma)</TITLE>
</HEAD><BODY>[ <A HREF="index.html">Predicate Database and Compiler</A> | <A HREF="../../index.html">Reference Manual</A> | <A HREF="../../fullindex.html">Alphabetic Index</A> ]
<H1>current_pragma(?Pragma)</H1>
Retrieves pragmas that are currently in effect for the context module
<DL>
<DT><EM>Pragma</EM></DT>
<DD>A variable, atom or compound term
</DD>
</DL>
<H2>Description</H2>
<P>    Used to test or enumerate currently set pragmas in the context module.
    This is typically only meaningful during the compilation process or
    during some other kind of source processing.
    </P><P>
    Source processing tools (or code invoked from source-processing tools,
    e.g. inline-transformations) can exploit the pragma facility to make
    their behaviour user-configurable. All they need to do is document the
    pragma names/structures and check for them using current_pragma/1.
    </P><P>
    Pragma recording works as follows: if the argument of the pragma directive
    is a structure, the new structure overwrites any previously recorded
    structure with the same functor.  If the argument is an atom, e.g.
    'xxx', then a previously recorded atom 'noxxx' is erased and 'xxx'
    recorded instead, and vice versa.
    </P>
<H3>Modes and Determinism</H3><UL>
<LI>current_pragma(+) is semidet
<LI>current_pragma(-) is nondet
</UL>
<H3>Modules</H3>
This predicate is sensitive to its module context (tool predicate, see @/2).
<H3>Exceptions</H3>
<DL>
<DT><EM>(5) type error </EM>
<DD>Pragma is not a variable, atom or compound term.
</DL>
<H2>Examples</H2>
<PRE>
    :- pragma(blah).

    ?- findall(P, current_pragma(P), L), writeln(L).
    [blah]

    :- pragma(myoption(on)).

    ?- findall(P, current_pragma(P), L), writeln(L).
    [blah, myoption(on)]

    :- pragma(myoption(off)).

    ?- findall(P, current_pragma(P), L), writeln(L).
    [blah, myoption(off)]

    :- pragma(noblah).

     ?- findall(P, current_pragma(P), L), writeln(L).
    [noblah, myoption(off)]

     ?- current_pragma(myoption(off)).
     Yes.
</PRE>
<H2>See Also</H2>
<A HREF="../../kernel/compiler/compile-1.html">compile / 1</A>, <A HREF="../../kernel/compiler/inline-2.html">inline / 2</A>, <A HREF="../../kernel/directives/pragma-1.html">pragma / 1</A>, <A HREF="../../lib/source_processor/index.html">library(source_processor)</A>
</BODY></HTML>
